
ASM=nasm
ASM_FLAGS=-f elf

CC=gcc
C_FLAGS=-ffreestanding -c -I ../include 

KERNEL_OBJS=entrance.o kernel.o idt.o idt_imp.o video.o klib.o \
	    kmath.o memory.o inout.o irq.o keyboard.o

kernel.bin: $(KERNEL_OBJS)
	ld --oformat binary -e main -Ttext 0x1000 -o kernel.bin $(KERNEL_OBJS)
#	objcopy -R .note -R .comment -g -O binary kernel.obj kernel.bin

entrance.o:
	$(ASM) $(ASM_FLAGS) -o entrance.o entrance.s

kernel.o:
	$(CC) $(C_FLAGS) -o kernel.o kernel.c

idt.o:
	$(CC) $(C_FLAGS) -o idt.o idt.c

idt_imp.o:
	$(ASM) $(ASM_FLAGS) -o idt_imp.o idt_imp.s

video.o:
	$(CC) $(C_FLAGS) -o video.o video.c

#vid_drv.o:
#	$(ASM) $(ASM_FLAGS) -o vid_drv.o vid_drv.s

klib.o:
	$(CC) $(C_FLAGS) -o klib.o klib.c

kmath.o:
	$(CC) $(C_FLAGS) -o kmath.o kmath.c

memory.o:
	$(CC) $(C_FLAGS) -o memory.o memory.c

inout.o:
	$(ASM) $(ASM_FLAGS) -o inout.o inout.s

irq.o:
	$(CC) $(C_FLAGS) -o irq.o irq.c

keyboard.o:
	$(CC) $(C_FLAGS) -o keyboard.o keyboard.c

clean:
	rm -f kernel.bin
	rm -f *.o*
	rm -f *~
